package com.qdu.controller;



import com.qdu.commons.Result;
import com.qdu.vo.WXAuth;
import com.qdu.service.IWeixinService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author:sanShi
 * @Description:{}
 * @date :2022/03/08
 */
@Slf4j
@RestController
@RequestMapping("/weixin")
@Api(value = "微信登录模块")
public class WeixinController extends BaseController{

    @Autowired
    IWeixinService weixinService;

    @GetMapping("/sessionId/{code}")
    @ApiOperation(value = "根据登录code获取sessionid")
    public String getSessionId(@PathVariable("code") String code){
        return  weixinService.getSessionId(code);
    }

    @PostMapping("/authLogin")
    @ApiOperation(value = "登录鉴权")
    public Result authLogin(@RequestBody WXAuth wxAuth) {
        Result result = weixinService.authLogin(wxAuth);
        log.info("{}",result);
        return result;
    }
}

